package cn.itcast.bos.test.base;

import java.io.File;

import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;


import freemarker.template.Configuration;
import freemarker.template.Template;



public class Freemarker {

	public void testOutput(){
		Configuration configuration = new Configuration(Configuration.VERSION_2_3_22);
		try {
			configuration.setDirectoryForTemplateLoading(new File("src/main/webapp/templates"));
			Template template = configuration.getTemplate("hello.ftl");
			
			Map<String, Object> paramterMap = new HashMap<String,Object>();
			paramterMap.put("title", "黑马程序员");
			paramterMap.put("msg", "你好，这是第一个Freemarker案例！");
			
			template.process(paramterMap, new PrintWriter(System.out));
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
}
